package videoconferencia

import grails.test.*

class ResponsavelTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }
	
	void testNotExists() {
		mockDomain(Responsavel)
		
		Responsavel responsavel = new Responsavel(nome:"Felipe", telefone:"(71)3333-4456", celular:"(75)2345-5676", email:"felp@felp.com")
		responsavel.save()
		
		Responsavel encontrado = Responsavel.findByNomeAndTelefone("Felipe", "(71)3333-4356")
		
		assertEquals encontrado, null
	}

    void testExists() {
		mockDomain(Responsavel)
		
		Responsavel responsavel = new Responsavel(nome:"Felipe", telefone:"(71)3333-4456", celular:"(75)2345-5676", email:"felp@felp.com")
		responsavel.save()
		
		Responsavel encontrado = Responsavel.findByNomeAndTelefone("Felipe", "(71)3333-4456")
		
		assertEquals responsavel, encontrado
    }
	
	void testCreateFalse() {
		mockDomain(Responsavel)
		
		Responsavel r1 = new Responsavel(nome:"Felipe", telefone:"(71)3333-4456", celular:"(75)2345-5676", email:"felp@felp.com")
		r1.save()
		
		Responsavel responsavel = null
		
		if(Responsavel.findByNomeAndTelefone("Felipe", "(71)3333-4456") == null) {
			responsavel = new Responsavel(nome:"Felipe", telefone:"(71)3333-4456", celular:"(75)2345-5676", email:"felp@felp.com")
			responsavel.save()
		}
		
		assertEquals responsavel, null
	}
	
	void testCreateTrue() {
		mockDomain(Responsavel)
		
		Responsavel responsavel = null
		
		if(Responsavel.findByNomeAndTelefone("Felipe", "(71)3333-4456") != null) {
			responsavel = new Responsavel(nome:"Felipe", telefone:"(71)3333-4456", celular:"(75)2345-5676", email:"felp@felp.com")
			responsavel.save()
		}
		
		assertEquals responsavel, Responsavel.findByNomeAndTelefone("Felipe", "(71)3333-4456")
	}
	
	void testUpdateFalse() {
		mockDomain(Responsavel)
	}
}
